#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>


#include "head.h"
#include "format.c"
#include "login.c"
#include "init.c"
#include "analyse.c"
#include "save_inode.c"
#include "read_blk.c"
#include "write_blk.c"
#include "release_blk.c"
#include "help.c"
#include "pathset.c"
#include "init_createfile.c"
#include "cd.c"
#include "rd.c"
#include "mkdir.c"
#include "create.c"
#include "open.c"
#include "read.c"
#include "write.c"
#include "del.c"
#include "logout.c"
#include "quit_err_free.c"
#include "cat.c"
#include "echo.c"

// 功能: 循环执行用户输入的命令, 直到logout
// "help", "cd", "dir", "mkdir", "creat", "open","read", "write", "close", "delete", "logout", "clear", "format","quit","rd"
void command(void)
{
    char cmd[100];
    system("cls");
    do
    {
    pathset();
    gets(cmd);
    switch(analyse(cmd))
    {
        case 0:
            help();
            break;
        case 1:
            cd();
            break;
        case 2:
            dir();
            break;
        case 3:
            mkdir();
            break;
        case 4:
            creat();
            break;
        case 5:
            open();
            break;
        case 6:
            read();
            break;
        case 7:
            write();
            break;
        case 8:
            close();
            break;
        case 9:
            del();
            break;
        case 10:
            logout();
            break;
        case 11:
            system("cls");
            break;
        case 12:
            format();
            init();
            free_user();
            login();
            break;
        case 13:
            quit();
            break;
        case 14:
            rd();
            break;
        case 15:
			cat();
            break;
		case 16:
			break;
        case 17:
            echo();
            break;
        case 18:
            errcmd();
            break;
        default:
            break;
        }
    }while(1);
}
// 主函数
int main(void)
{
    login();
    init();
    command();
    return 0;
}
